﻿using System.Linq;
using Media.Core.Entities;
using Media.Core.Models;

namespace Media.Core.Data.Queries
{
    public class Movies
    {
        private static MediaEntitiesDataContext db = new MediaEntitiesDataContext();

        public static Movie GetMovieDetails(int Id)
        {
            var MovieDetails2 = db.Media_Movies.Single(m => m.Id == Id);

            var MovieDetails = (from m in db.Media_Movies
                                where m.Id == Id
                                select new
                                {
                                    Id = m.Id,
                                    MovieTitle = m.MovieTitle,
                                    Director = m.Director
                                }).Single();

            //DataTable table = Linq.ToDataTable(MovieDetails);

            var movies2 = new Movie
            {
                Id = MovieDetails.Id,
                Title = MovieDetails.MovieTitle,
                Director = MovieDetails.Director,
                Year = MovieDetails2.ReleaseDate
            };

            return movies2;
        }
    }
}